if ( !window.controller ) throw new Error( '"controller" not initialized' );
if(!controller.user.property){
	controller.user.property = ( function(){
		var $ = controller;
		
			
		var PProperty = function(data, user){
			PropertySuperPrototype.constructor.call( this );
			this._id 		= data.id;
			this._value 	= data.value;
			//if(this._id==1){
				//this._value -= 50;
			//}
			//console.log(data);
			if(controller.user.property.Description[this._id]){
				this._type 		= controller.user.property.Description[this._id].type;
				this._rel_max 	= controller.user.property.Description[this._id].rel_max;
				this._rel_speed = controller.user.property.Description[this._id].rel_speed;
			}
			if(this._type == "DYNAMIC"){
				this.__user = user;
				this.__user.addEventListener("START_TIMER_EVENT", this, startTimer);
			}
			
		}
		
		//;
		$.extend( PProperty, $.events.EventDispatcher );
		var PPropertyPrototype 		= PProperty.prototype,
			PropertySuperPrototype 	= PProperty.superPrototype;
			
		
		var dispatchEvent= PropertySuperPrototype.dispatchEvent;
		var EEvent = $.events.Event;/**/
		
		PPropertyPrototype._id 			= null;
		PPropertyPrototype._value 		= null;
		PPropertyPrototype._type 		= null;
		PPropertyPrototype._rel_max 	= null;
		PPropertyPrototype._rel_spped 	= null;
		PPropertyPrototype.__user 		= null;
		PPropertyPrototype.__timer 		= null;
		
		
		var startTimer = function(){
		// Получаем событие о том что можно начинать тики
			// Получаем ссылки на зависимые проперти
			this._rel_max = this.__user.getProperty(this._rel_max);
			this._rel_speed = this.__user.getProperty(this._rel_speed);
			if(this._rel_speed.getValue() > 0){
				//console.log("Start Timer "+ this._id + " max " + this._rel_max._id + " speed "+ this._rel_speed._id);
				this.__timer = new $.utils.Timer(this._rel_speed.getValue() * 1000, 0, this._id);
				this.__timer.addEventListener("timer", this, TimerProcessor);
				this.__timer.start();
			}
		}
		
		var TimerProcessor = function(e){
			//console.log("Tick:" + this._id);
			if(this._value != this._rel_max.getValue()){
				var val = this._value;
				var max = this._rel_max.getValue();
				switch(this._id){
					case(1):// HP востанавливается в 1 тик 1% 
						val += Math.round(max / 100);
						if(val > max){
							val = max;
						}
					break;
					default:
						val +=  1;
				}
				this.update( val );
			}
		}
		
		
		/**
		* Если свойство реально обновится только тогда всплывет событие
		*/
		
		PPropertyPrototype.update = function(value){
			if(this._value != value){
				//console.log( "updateProperty ID:" +this._id+ " Value:" +value+" speed:"+this._rel_speed.getValue()+ " max:"+this._rel_max.getValue());
				if(
					(this._type == "DYNAMIC" && this._rel_max.getValue() >= value)
					|| this._type == "STATIC"
				){
					this._value = value;
					var event  = new EEvent("PROPERTY_UPDATE");
					event.data = {"id": this._id, "value": this._value};
					dispatchEvent.call(this, event);
				}
			}
		}

		PPropertyPrototype.getId = function(){
			return this._id;
		}
		PPropertyPrototype.getValue = function(){
			return this._value;
		}
		PPropertyPrototype.getType = function(){
			return this._type;
		}
		PPropertyPrototype.getRelMax = function(){
			return this._rel_max;
		}
		PPropertyPrototype.getRelSpeed = function(){
			return this._rel_speed;
		}
		/*PPropertyPrototype.callsEvent = function(){
			var event 	 = new EEvent( "PROPERTY_EVENT" );
				dispatchEvent.call( this, event);
		}*/
	
		return PProperty;
	}());
}

controller.user.property.Description = {
	1:{"id":1,"name":"HP",     	 		"description":"HP",					"type":"DYNAMIC",	"rel_max":2,	"rel_speed":3},
	2:{"id":2,"name":"HP_MAX",  		"description":"Уровень жизни",		"type":"STATIC",	"rel_max":null,	"rel_speed":null, 				a_conv:"+", b_conv:"HP"},
	3:{"id":3,"name":"HP_SPEED",		"description":"Скорость рег. жизни",			"type":"STATIC",	"rel_max":null,	"rel_speed":null,	a_conv:" 1% -", b_conv:"сек."},
	4:{"id":4,"name":"LOCATION",		"description":"LOCATION",			"type":"DYNAMIC",	"rel_max":5,	"rel_speed":6},
	5:{"id":5,"name":"LOCATION_MAX",	"description":"LOCATION_MAX",		"type":"STATIC",	"rel_max":null,	"rel_speed":null},
	6:{"id":6,"name":"LOCATION_SPEED",	"description":"LOCATION_SPEED",		"type":"STATIC",	"rel_max":null,	"rel_speed":null},
	7:{"id":7,"name":"EXP_COOF",		"description":"Коэфицент опыта",	"type":"STATIC",	"rel_max":null,	"rel_speed":null, 				a_conv:"x", b_conv:""},
	9:{"id":9,"name":"LOSS",			"description":"Урон оружия",		"type":"STATIC",	"rel_max":null,	"rel_speed":null},
	10:{"id":10,"name":"RESERVATION",	"description":"Броня",				"type":"STATIC","rel_max":null,"rel_speed":null},
	11:{"id":11,"name":"FARM_COUNT",	"description":"Количество построек","type":"STATIC","rel_max":null,"rel_speed":null},
	12:{"id":12,"name":"FARM_LEVEL",	"description":"Качественный уровень постройки","type":"STATIC","rel_max":null,"rel_speed":null},
	13:{"id":13,"name":"MAX_BAND",		"description":"Макс. кол-во человек в банде","type":"STATIC","rel_max":null,"rel_speed":null},
	14:{"id":14,"name":"CRIT_CHANCE",	"description":"Шанс критического урона","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:"+", b_conv:"%"},
	15:{"id":15,"name":"EVAD_CHANCE",	"description":"Шанс увернуться от ударов","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:"+", b_conv:"%"},
	16:{"id":16,"name":"ANTICRIT_CHANCE","description":"Шанс избежать кр. урон","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:"+", b_conv:"%"},
	17:{"id":17,"name":"ANTIEVAD_CHANCE","description":"Шанс попасть по противнику","type":"STATIC","rel_max":null,"rel_speed":null, 			a_conv:"+", b_conv:"%"},
	18:{"id":18,"name":"MONEY_PROTECTED","description":"Тайник на баксы","type":"STATIC","rel_max":null,"rel_speed":null},
	19:{"id":19,"name":"LOSS_POWER",		"description":"Мощность Урона","type":"STATIC","rel_max":null,"rel_speed":null, 					a_conv:"+", b_conv:"%"},
	20:{"id":20,"name":"RESERVATION_POWER",	"description":"Мощность защиты","type":"STATIC","rel_max":null,"rel_speed":null, 					a_conv:"+", b_conv:"%"},
	21:{"id":21,"name":"PRISON",			"description":"Шанс угодить в тюрьму","type":"DYNAMIC","rel_max":22,"rel_speed":23},
	22:{"id":22,"name":"PRISON_MAX",		"description":"PRISON_MAX","type":"STATIC","rel_max":null,"rel_speed":null},
	23:{"id":23,"name":"PRISON_SPEED",		"description":"PRISON_SPEED","type":"STATIC","rel_max":null,"rel_speed":null},
	24:{"id":24,"name":"PRISON_FREE",		"description":"Освобождение из тюрьмы","type":"DYNAMIC","rel_max":25,"rel_speed":26},
	25:{"id":25,"name":"PRISON_FREE_MAX",	"description":"Освобождение из тюрьмы Макс","type":"STATIC","rel_max":null,"rel_speed":null},
	26:{"id":26,"name":"PRISON_FREE_SPEED",	"description":"Освобождение из тюрьмы Скорость","type":"STATIC","rel_max":null,"rel_speed":null},
	27:{"id":27,"name":"IS_PRISON",			"description":"IS_PRISON","type":"DYNAMIC","rel_max":28,"rel_speed":29},
	28:{"id":28,"name":"IS_PRISON_MAX",		"description":"IS_PRISON_MAX","type":"STATIC","rel_max":null,"rel_speed":null},
	29:{"id":29,"name":"IS_PRISON_SPEED",	"description":"IS_PRISON_SPEED","type":"STATIC","rel_max":null,"rel_speed":null},
	30:{"id":30,"name":"COOF_FARM",			"description":"Коэфицент прибыли с фермы","type":"STATIC","rel_max":null,"rel_speed":null},
	31:{"id":31,"name":"COOF_MONEY_BATTLE",	"description":"Коэфицент баксов [1x1]","type":"STATIC","rel_max":null,"rel_speed":null},
	32:{"id":32,"name":"COOF_MONEY_BAND",	"description":"Коэфицент баксов [бизнеса]","type":"STATIC","rel_max":null,"rel_speed":null},
	33:{"id":33,"name":"PERK_CRIT",			"description":"Следующий удар 100% крит","type":"STATIC","rel_max":null,"rel_speed":null},
	34:{"id":34,"name":"PERK_POISON",		"description":"Отравить противника на ","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:"", b_conv:"HP"},
	35:{"id":35,"name":"PERK_ANTIPOISON",	"description":"Анти-Отрава","type":"STATIC","rel_max":null,"rel_speed":null},
	36:{"id":36,"name":"PERK_VAMPIR",		"description":"Востановить","type":"STATIC","rel_max":null,"rel_speed":null, a_conv:"", b_conv:"% HP от ненесенного урона в этот ход"},
	37:{"id":37,"name":"PERK_BLOODON",		"description":"Противник получит ","type":"STATIC","rel_max":null,"rel_speed":null, a_conv:"", b_conv:"% нанесенного вам урона"},
	38:{"id":38,"name":"PERK_HEALWODMG",	"description":"Пропустить ход и востановить ","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:"", b_conv:"% HP"},
	39:{"id":39,"name":"PERK_NEXTx2DMG",	"description":"Пропустить ход и след удар х2 урона","type":"STATIC","rel_max":null,"rel_speed":null},
	40:{"id":40,"name":"PERK_EVADDMG",		"description":"Удар пройдет даже если противник увернется","type":"STATIC","rel_max":null,"rel_speed":null},
	41:{"id":41,"name":"PERK_COMBO",		"description":"Серия","type":"STATIC","rel_max":null,"rel_speed":null, 				a_conv:" из ", b_conv:" ударов"},
	42:{"id":42,"name":"PERK_MASKENEMY",	"description":"Противник нанесет удар по члену своей комманды","type":"STATIC","rel_max":null,"rel_speed":null},
	43:{"id":43,"name":"PERK_KILLCHANCE",	"description":"Противник погибнет если его HP ","type":"STATIC","rel_max":null,"rel_speed":null, a_conv:" меньше ", b_conv:" % и вы по нему попадете в этот ход"},
	44:{"id":44,"name":"CRIT_POWER",		"description":"Увеличивает силу крит удара","type":"STATIC","rel_max":null,"rel_speed":null},
	45:{"id":45,"name":"ANTICRIT_POWER",	"description":"Увеличивает силу вашего крит удара","type":"STATIC","rel_max":null,"rel_speed":null},
	46:{"id":46,"name":"PERK_USE_CHANCE",	"description":"Вероятность сработать","type":"STATIC","rel_max":null,"rel_speed":null, a_conv:"", b_conv:" %"},
	47:{"id":47,"name":"ENERGY",			"description":"ENERGY","type":"DYNAMIC","rel_max":48,"rel_speed":49},
	48:{"id":48,"name":"ENERGY_MAX",		"description":"Запас энергии", "type":"STATIC","rel_max":null,"rel_speed":null, a_conv:" +", b_conv:""},
	49:{"id":49,"name":"ENERGY_SPEED",		"description":"Время регенерации энергии","type":"STATIC","rel_max":null,"rel_speed":null, a_conv:" 1 ед. -", b_conv:" сек."},
	50:{"id":50,"name":"CRAFT_LEVEL",		"description":"CRAFT_LEVEL","type":"STATIC","rel_max":null,"rel_speed":null},
	51:{"id":51,"name":"CRAFT_FARM_LEVEL",	"description":"CRAFT_FARM_LEVEL","type":"STATIC","rel_max":null,"rel_speed":null},
	53:{"id":53,"name":"IS_PATROL",			"description":"IS_PATROL","type":"DYNAMIC","rel_max":54,"rel_speed":55},
	54:{"id":54,"name":"IS_PATROL_MAX",		"description":"IS_PATROL_MAX","type":"STATIC","rel_max":null,"rel_speed":null},
	55:{"id":55,"name":"IS_PATROL_SPEED",	"description":"IS_PATROL_SPEED","type":"STATIC","rel_max":null,"rel_speed":null},
	56:{"id":56,"name":"LOCATION_ID",		"description":"LOCATION_ID","type":"STATIC","rel_max":null,"rel_speed":null},
	57:{"id":57,"name":"CHANCE",			"description":"CHANCE","type":"STATIC","rel_max":null,"rel_speed":null},
	58:{"id":58,"name":"PATROL_TIME",		"description":"PATROL_TIME","type":"STATIC","rel_max":null,"rel_speed":null},
	59:{"id":59,"name":"CRAFT_LEVEL1",		"description":"CRAFT_LEVEL1","type":"STATIC","rel_max":null,"rel_speed":null},
	60:{"id":60,"name":"CRAFT_LEVEL2",		"description":"CRAFT_LEVEL2","type":"STATIC","rel_max":null,"rel_speed":null},
	61:{"id":61,"name":"CRAFT_LEVEL3",		"description":"CRAFT_LEVEL3","type":"STATIC","rel_max":null,"rel_speed":null},
	62:{"id":62,"name":"CRAFT_LEVEL4",		"description":"CRAFT_LEVEL4","type":"STATIC","rel_max":null,"rel_speed":null},
	63:{"id":63,"name":"CRAFT_LEVEL5",		"description":"CRAFT_LEVEL5","type":"STATIC","rel_max":null,"rel_speed":null},
	64:{"id":64,"name":"CRAFT_LEVEL6",		"description":"CRAFT_LEVEL6","type":"STATIC","rel_max":null,"rel_speed":null},
	65:{"id":65,"name":"CRAFT_LEVEL7",		"description":"CRAFT_LEVEL7","type":"STATIC","rel_max":null,"rel_speed":null},
	66:{"id":66,"name":"CRAFT_LEVEL8",		"description":"CRAFT_LEVEL8","type":"STATIC","rel_max":null,"rel_speed":null},
	67:{"id":67,"name":"CRAFT_LEVEL9",		"description":"CRAFT_LEVEL9","type":"STATIC","rel_max":null,"rel_speed":null},
	68:{"id":68,"name":"CRAFT_LEVEL10",		"description":"CRAFT_LEVEL10","type":"STATIC","rel_max":null,"rel_speed":null},
	69:{"id":69,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null},
	70:{"id":70,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null},
	71:{"id":71,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null},
	72:{"id":72,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null},
	73:{"id":73,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null},
	74:{"id":74,"name":"IS_VIP",			"description":"Флаг того что вип есть","type":"STATIC","rel_max":null,"rel_speed":null}
};/**/